package top.wecreate.view;

import android.content.Context;
import android.util.DisplayMetrics;

public class Utils {

	private static float app_density = 0.1f;

	private static int screen_width;

	private static int screen_height;

	public static int dip2px(Context context, float dpValue) {
		if (app_density == 0.1f) {
			if (null == context) {
				return (int) dpValue;
			}
			DisplayMetrics metrics = context.getResources().getDisplayMetrics();
			app_density = metrics.density;
			screen_width = metrics.widthPixels;
			screen_height = metrics.heightPixels;
		}
		return (int) (dpValue * app_density + 0.5f);
	}

	public static int getScreenWidth() {
		return screen_width;
	}

	public static int getScreenHeight() {
		return screen_height;
	}
}
